---------------------------------------------------------------------------------------------------------------------- --Actions ---------------------------------------------------------------------------------------------------------------------- -- Обычное поведение class "action_process_death" function action_process_death:__init(obj, storage) self.object = obj self.st = storage end function action_process_death:death_callback(victim, who) if who ~= nil then printf("[%s] killed by [%s]", victim:name(), who:name() ) db.storage[victim:id()].death.killer = who:id() else printf("[%s] killed by [Unknown]", victim:name()) db.storage[victim:id()].death.killer = -1 end if db.actor then if self.st.info then xr_logic.pick_section_from_condlist(db.actor, self.object, self.st.info) end if self.st.info2 then xr_logic.pick_section_from_condlist(db.actor, self.object, self.st.info2) end end end ---------------------------------------------------------------------------------------------------------------------- -- binder ---------------------------------------------------------------------------------------------------------------------- function setup_generic_scheme(npc,ini,scheme,section,stype,temp) local death_section = ini:r_string_ex(section,"on_death") if (death_section) then local st = xr_logic.assign_storage_and_bind(npc,ini,"death",death_section,temp) end end function add_to_binder(npc,ini,scheme,section,st,temp) st.action = action_process_death(npc,st) xr_logic.subscribe_action_for_events(npc,st,st.action) end function reset_generic_scheme(npc,scheme,section,stype,st) local death_section = st.ini:r_string_ex(st.section_logic,"on_death") if death_section then if not st.ini:section_exist(death_section) then abort("There is no section [%s] for npc [%s]", death_section, npc:name()) end local tmp = st.ini:r_string_ex(death_section,"on_info") if tmp then st.death.info = xr_logic.parse_condlist(npc, death_section, "death", tmp) end tmp = st.ini:r_string_ex(death_section,"on_info2") if tmp then st.death.info2 = xr_logic.parse_condlist(npc, death_section, "death", tmp) end end end